﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyFrameWork.Common
{
    [Serializable]
    public partial class Pager
    {
        /// <summary>
        /// 总页数
        /// </summary>
        private int _pageCount;

        public int PageCount
        {
            get
            {
                if (PageSize != 0)
                {
                    return RecordCount % PageSize == 0 ? RecordCount / PageSize : RecordCount / PageSize + 1;
                }
                else
                {
                    return 0;
                }
            }
        }

        /// <summary>
        /// 当前页
        /// </summary>
        private int _pageIndex;

        public int PageIndex
        {
            get { return _pageIndex; }
            set { _pageIndex = value; }
        }

        /// <summary>
        /// 页数
        /// </summary>
        private int _pageSize;

        public int PageSize
        {
            get { return _pageSize; }
            set { _pageSize = value; }
        }

        /// <summary>
        /// 开始行数
        /// </summary>
        private int _beginRow;

        public int BeginRow
        {
            get { return (this.PageIndex - 1) * this.PageSize + 1; }
        }

        /// <summary>
        /// 结尾行数
        /// </summary>
        private int _endRow;

        public int EndRow
        {
            get { return this.PageIndex * this.PageSize; }
        }

        /// <summary>
        /// 排序行
        /// </summary>
        private string _sortColumn;

        public string SortColumn
        {
            get { return _sortColumn; }
            set { _sortColumn = value; }
        }

        /// <summary>
        /// 排序规则
        /// </summary>
        private string _sortMode;

        public string SortMode
        {
            get { return _sortMode; }
            set { _sortMode = value; }
        }

        /// <summary>
        /// 总行数
        /// </summary>
        private int _recordCount;

        public int RecordCount
        {
            get { return _recordCount; }
            set { _recordCount = value; }
        }
        public string GetJson()
        {
            return JsonUtility.ToJSON(this);
        }
    }

    public class ListCondition
    {
        public Pager _listPager = new Pager();
        public Pager ListPager
        {
            get { return _listPager; }
            set { _listPager = value; }
        }

        public Dictionary<string, string> _searchCondition = new Dictionary<string, string>();
        public Dictionary<string, string> SearchCondition
        {
            get { return _searchCondition; }
            set { _searchCondition = value; }
        }
    }

}